<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 *
 * @author Joker
 * `user_id` int(11) NOT NULL COMMENT '发送者id',
	`dialog_id` int(11) NOT NULL COMMENT '对话ID',
	`message` text NOT NULL COMMENT '内容',
	`semder_remove` tinyint(1) NOT NULL DEFAULT 0 COMMENT '发送者已移除  0 正常，1 已移除。',
	`recipient_remove` tinyint(1) NOT NULL DEFAULT 0 COMMENT '接受者已移除 0 正常，1 已移除',
	`receipt` int(10) DEFAULT NULL COMMENT '接受者的ID',       
 */
class Inbox extends Model
{
    protected $table="inbox";
    
    protected $primaryKey = 'id';
    
    protected $fillable = ['id','user_id','dialog_id','message','semder_remove','recipient_remove','receipt'];
    
    /**
     * 获取dialog 信息
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function dialog()
    {
        return $this->belongsTo('App\Models\InboxDialog');
    }
    
    public function sender()
    {
        return $this->hasOne('App\User','id','user_id');
    }
    
    public function recipient()
    {
        return $this->hasOne('App\User','id','receipt');
    }
}